package com.framework.service.core.controller;


import com.framework.common.controller.BaseController;
import com.framework.common.request.CustomInfoReq;
import com.framework.service.core.dao.model.CustomInfo;
import com.framework.service.core.service.ICustomInfoService;
import com.framework.core.api.request.CustomInfoCertReq;
import com.framework.core.api.request.CustomInfoQuerytReq;
import com.framework.core.api.response.CustomInfoRes;
import com.framework.service.core.dao.model.CustomInfo;
import com.framework.service.core.service.ICustomInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhoubb
 * @version V1.0
 * @Date 2020/4/11 20:34
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/custom")
@Api(value = "CustomApi", description = "用户信息管理接口")
public class CustomController extends BaseController {

    @Autowired
    private ICustomInfoService customInfoService;

    @ApiOperation(value = "新增客户", httpMethod = "POST")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    @ResponseBody
    public int insertCustom(CustomInfoReq customInfoReq) {
        CustomInfo customInfo = new CustomInfo();
        BeanUtils.copyProperties(customInfoReq,customInfo);
        return customInfoService.insertCustomInfo(customInfo);
    }

    @ApiOperation(value = "用户实名认证", httpMethod = "POST")
    @RequestMapping(value = "/cert",method = RequestMethod.POST)
    @ResponseBody
    public CustomInfoRes certCustomInfo(CustomInfoCertReq customInfoCertReq) {
        return customInfoService.certCustomInfo(customInfoCertReq);
    }

    @ApiOperation(value = "查询用户信息", httpMethod = "GET")
    @RequestMapping(value = "/getCustomInfoByUserId",method = RequestMethod.GET)
    @ResponseBody
    public CustomInfoRes getCustomInfoByUserId(@ApiParam(value = "用户id") @RequestParam String userId) {
        CustomInfoQuerytReq customInfoQuerytReq = new CustomInfoQuerytReq();
        customInfoQuerytReq.setUserId(Long.valueOf(userId));
        return customInfoService.getCustomInfo(customInfoQuerytReq);
    }
}
